
Public Class ColorSegmentationSettings

  Inherits System.Windows.Forms.Form

#Region " Windows Form Designer generated code "

  Public Sub New()
    MyBase.New()

    'This call is required by the Windows Form Designer.
    InitializeComponent()

    'Add any initialization after the InitializeComponent() call
  End Sub

  'Form overrides dispose to clean up the component list.
  Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
    If disposing Then
      If Not (components Is Nothing) Then
        components.Dispose()
      End If
    End If
    MyBase.Dispose(disposing)
  End Sub

  'Required by the Windows Form Designer
  Private components As System.ComponentModel.IContainer

  'NOTE: The following procedure is required by the Windows Form Designer
  'It can be modified using the Windows Form Designer.  
  'Do not modify it using the code editor.
  Friend WithEvents ttAnnotation As System.Windows.Forms.ToolTip
  Friend WithEvents Label2 As System.Windows.Forms.Label
  Friend WithEvents rdPoint As System.Windows.Forms.RadioButton
  Friend WithEvents rdRegion As System.Windows.Forms.RadioButton
  Friend WithEvents rdImage As System.Windows.Forms.RadioButton
  Friend WithEvents trkdE As System.Windows.Forms.TrackBar
  Friend WithEvents lbldE As System.Windows.Forms.Label
  Friend WithEvents chkdC As System.Windows.Forms.CheckBox
  Friend WithEvents chkInvert As System.Windows.Forms.CheckBox
  <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
    Me.components = New System.ComponentModel.Container
    Me.ttAnnotation = New System.Windows.Forms.ToolTip(Me.components)
    Me.rdPoint = New System.Windows.Forms.RadioButton
    Me.rdRegion = New System.Windows.Forms.RadioButton
    Me.rdImage = New System.Windows.Forms.RadioButton
    Me.trkdE = New System.Windows.Forms.TrackBar
    Me.lbldE = New System.Windows.Forms.Label
    Me.Label2 = New System.Windows.Forms.Label
    Me.chkdC = New System.Windows.Forms.CheckBox
    Me.chkInvert = New System.Windows.Forms.CheckBox
    CType(Me.trkdE, System.ComponentModel.ISupportInitialize).BeginInit()
    Me.SuspendLayout()
    '
    'rdPoint
    '
    Me.rdPoint.FlatStyle = System.Windows.Forms.FlatStyle.Flat
    Me.rdPoint.Location = New System.Drawing.Point(277, 48)
    Me.rdPoint.Name = "rdPoint"
    Me.rdPoint.Size = New System.Drawing.Size(88, 24)
    Me.rdPoint.TabIndex = 11
    Me.rdPoint.Text = "Point"
    Me.ttAnnotation.SetToolTip(Me.rdPoint, "Searches for new points starting from clicked point only")
    '
    'rdRegion
    '
    Me.rdRegion.Checked = True
    Me.rdRegion.FlatStyle = System.Windows.Forms.FlatStyle.Flat
    Me.rdRegion.Location = New System.Drawing.Point(189, 48)
    Me.rdRegion.Name = "rdRegion"
    Me.rdRegion.Size = New System.Drawing.Size(88, 24)
    Me.rdRegion.TabIndex = 10
    Me.rdRegion.TabStop = True
    Me.rdRegion.Text = "Region"
    Me.ttAnnotation.SetToolTip(Me.rdRegion, "Searches for new points close to existing region")
    '
    'rdImage
    '
    Me.rdImage.FlatStyle = System.Windows.Forms.FlatStyle.Flat
    Me.rdImage.Location = New System.Drawing.Point(101, 48)
    Me.rdImage.Name = "rdImage"
    Me.rdImage.Size = New System.Drawing.Size(88, 24)
    Me.rdImage.TabIndex = 9
    Me.rdImage.Text = "Image"
    Me.ttAnnotation.SetToolTip(Me.rdImage, "Searches for new points in the whole image")
    '
    'trkdE
    '
    Me.trkdE.LargeChange = 10
    Me.trkdE.Location = New System.Drawing.Point(96, 8)
    Me.trkdE.Maximum = 100
    Me.trkdE.Name = "trkdE"
    Me.trkdE.Size = New System.Drawing.Size(272, 42)
    Me.trkdE.SmallChange = 5
    Me.trkdE.TabIndex = 6
    Me.trkdE.TickFrequency = 10
    Me.trkdE.Value = 30
    '
    'lbldE
    '
    Me.lbldE.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
    Me.lbldE.Location = New System.Drawing.Point(8, 16)
    Me.lbldE.Name = "lbldE"
    Me.lbldE.Size = New System.Drawing.Size(72, 16)
    Me.lbldE.TabIndex = 7
    Me.lbldE.Text = "dE*"
    '
    'Label2
    '
    Me.Label2.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
    Me.Label2.Location = New System.Drawing.Point(8, 52)
    Me.Label2.Name = "Label2"
    Me.Label2.Size = New System.Drawing.Size(64, 16)
    Me.Label2.TabIndex = 8
    Me.Label2.Text = "Grow area"
    '
    'chkdC
    '
    Me.chkdC.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
    Me.chkdC.Location = New System.Drawing.Point(8, 80)
    Me.chkdC.Name = "chkdC"
    Me.chkdC.RightToLeft = System.Windows.Forms.RightToLeft.Yes
    Me.chkdC.Size = New System.Drawing.Size(152, 16)
    Me.chkdC.TabIndex = 13
    Me.chkdC.Text = "Illumination independent"
    Me.chkdC.TextAlign = System.Drawing.ContentAlignment.MiddleRight
    '
    'chkInvert
    '
    Me.chkInvert.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
    Me.chkInvert.Location = New System.Drawing.Point(200, 80)
    Me.chkInvert.Name = "chkInvert"
    Me.chkInvert.RightToLeft = System.Windows.Forms.RightToLeft.Yes
    Me.chkInvert.Size = New System.Drawing.Size(112, 16)
    Me.chkInvert.TabIndex = 14
    Me.chkInvert.Text = "Invert mask"
    Me.chkInvert.TextAlign = System.Drawing.ContentAlignment.MiddleRight
    '
    'ColorSegmentationSettings
    '
    Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
    Me.ClientSize = New System.Drawing.Size(370, 106)
    Me.ControlBox = False
    Me.Controls.Add(Me.chkInvert)
    Me.Controls.Add(Me.chkdC)
    Me.Controls.Add(Me.rdPoint)
    Me.Controls.Add(Me.rdRegion)
    Me.Controls.Add(Me.rdImage)
    Me.Controls.Add(Me.Label2)
    Me.Controls.Add(Me.lbldE)
    Me.Controls.Add(Me.trkdE)
    Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow
    Me.Name = "ColorSegmentationSettings"
    Me.Text = "Color segmentation settings"
    CType(Me.trkdE, System.ComponentModel.ISupportInitialize).EndInit()
    Me.ResumeLayout(False)

  End Sub

#End Region

    Public Property Mode() As ROIEditor.ColorSegmentationMode
        Get
            If rdImage.Checked Then Return ROIEditor.ColorSegmentationMode.Image
            If rdPoint.Checked Then Return ROIEditor.ColorSegmentationMode.Point
            If rdRegion.Checked Then Return ROIEditor.ColorSegmentationMode.Region
        End Get
        Set(ByVal Value As ROIEditor.ColorSegmentationMode)
            Select Case Value
                Case ROIEditor.ColorSegmentationMode.Image
                    rdImage.Checked = True
                    rdPoint.Checked = False
                    rdRegion.Checked = False
                Case ROIEditor.ColorSegmentationMode.Point
                    rdPoint.Checked = True
                    rdImage.Checked = False
                    rdRegion.Checked = False
                Case ROIEditor.ColorSegmentationMode.Region
                    rdRegion.Checked = True
                    rdPoint.Checked = False
                    rdImage.Checked = False
            End Select
        End Set
    End Property

  Public Property dE() As Single
    Get
            Return CSng(trkdE.Value / 10)
    End Get
    Set(ByVal Value As Single)
      trkdE.Value = CInt(Value * 10)
    End Set
  End Property

  Public Property ChromaticInfoOnly() As Boolean
    Get
      Return chkdC.Checked
    End Get
    Set(ByVal Value As Boolean)
      chkdC.Checked = Value
    End Set
  End Property

  Public Property Invert() As Boolean
    Get
      Return chkInvert.Checked
    End Get
    Set(ByVal Value As Boolean)
      chkInvert.Checked = Value
    End Set
  End Property

  Private Sub trkdE_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles trkdE.ValueChanged
    DrawSlider()
  End Sub

  Private Sub DrawSlider()
    If chkdC.Checked Then
      lbldE.Text = "dC* = " & trkdE.Value / 10
    Else
      lbldE.Text = "dE* = " & trkdE.Value / 10
    End If
  End Sub

  Private Sub chkdC_CheckStateChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles chkdC.CheckStateChanged
    DrawSlider()
  End Sub
End Class
